package fantasyfootball.data.entities;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 * Class: 605.441 
 * Group: Richard Koretke, Kay Jantharasorn, Israel Rivera.
 * 
 * @author Israel Rivera
 * 
 */
@Entity(name="FantasyManager")
public class FantasyManager implements Serializable{
	
	private static final long serialVersionUID = -5280267619289219301L;

	private String logonName;
	private String email;
	private String firstName;
	private String lastName;
	
	// TODO CHECK DATATYPE
	private String password;
	
	private Set<FantasyLeague> fantasyLeagues;
	private Set<FantasyTeam> fantasyTeams;
	
	@Id
	@Column(name="LogonName", nullable=false)
	public String getLogonName() {
		return logonName;
	}
	
	public void setLogonName(String logonName) {
		this.logonName = logonName;
	}
	
	@Column(name="Email", nullable=false)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	@Column(name="FirstName", nullable=false)
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	@Column(name="LastName", nullable=false)
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	@Column(name="Password", nullable=false)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@OneToMany(fetch=FetchType.LAZY, mappedBy="fantasyManager")
	public Set<FantasyLeague> getFantasyLeagues() {
		return fantasyLeagues;
	}

	public void setFantasyLeagues(Set<FantasyLeague> fantasyLeagues) {
		this.fantasyLeagues = fantasyLeagues;
	}
	
	@OneToMany(fetch=FetchType.LAZY, mappedBy="fantasyManager")
	public Set<FantasyTeam> getFantasyTeams() {
		return fantasyTeams;
	}
	
	public void setFantasyTeams(Set<FantasyTeam> fantasyTeams) {
		this.fantasyTeams = fantasyTeams;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((logonName == null) ? 0 : logonName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FantasyManager other = (FantasyManager) obj;
		if (logonName == null) {
			if (other.logonName != null)
				return false;
		} else if (!logonName.equals(other.logonName))
			return false;
		return true;
	}
}